import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;

public class 递增三元组_前缀和 {
    static int N = 100010;
    static int[] a = new int[N];
    static int[] b = new int[N];
    static int[] c = new int[N];
    static int[] s1 = new int[N];
    static int[] s2 = new int[N];

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintStream out = new PrintStream(System.out);
        int n = Integer.parseInt(in.readLine());
        //a = new int[n + 1];b = new int[n + 1];c = new int[n + 1];s1 = new int[n + 1]; s2 = new int[n + 1];
        String[] str1 = in.readLine().split(" ");
        String[] str2 = in.readLine().split(" ");
        String[] str3 = in.readLine().split(" ");

        for (int i = 1; i <= n; i++) {
            a[i] = Integer.parseInt(str1[i - 1]);
            b[i] = Integer.parseInt(str2[i - 1]);
            c[i] = Integer.parseInt(str3[i - 1]);
            a[i]++;b[i]++;c[i]++;
        }
        //
        for (int i = 1; i <=n ; i++) s1[a[i]]++;
        for (int i = 1; i <N ; i++) s1[i] = s1[i-1]+s1[i];

        for (int i = 1; i <=n ; i++) s2[c[i]]++;
        for (int i = 1; i <N ; i++) s2[i] = s2[i-1]+s2[i];

//        System.out.println(Arrays.toString(s1));
//        System.out.println(Arrays.toString(s2));

        long count=0;
        for (int i = 1; i <=n ; i++) {
            count+=s1[b[i]-1]*(s2[N-1] - s2[b[i]]);
            //System.out.println(s1[b[i]-1]+" * "+(s2[N-1]-s2[b[i]]));
        }

        System.out.println(count);

    }
}

